<?php


namespace app\model\vipshop;

use app\model\BaseModel;

class VipProduct extends BaseModel
{
    // 设置当前模型对应的完整数据表名称
    protected $connection = 'vip_shop';

    protected $table = 'ns_goods';

    protected $pk = 'goods_id';

    public function getDocIdAttr($value,$data)
    {
        return base64_encode($data['goods_id'].'|vipshop');
    }

    public function getDataSourceAttr($value,$data)
    {
        return 2;
    }

    public function getIsDeletedAttr($value)
    {
        return $value ? 1 : 0;
    }

    public function getCreateTimeAttr($value)
    {
        return $value ? $value : 0;
    }

    public function getUpdateTimeAttr($value)
    {
        return $value ? $value : 0;
    }

    public function getImgIdArrayAttr($value)
    {
        return $value ?  $value : '';
    }

    public function getGoodsSpecFormatAttr($value)
    {
        return $value ? json_decode($value,true) : [];
    }

    public function skus()
    {
        return $this->hasMany('VipSku','goods_id');
    }
}